﻿@model RiverCruise.Models.UserManagement.UsersViewModel

@{
    ViewBag.Title = "Manage users";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="container-fluid">
    
    <h2>
        <span class="btn-group pull-right">
            <a href="@Url.Action("Add", "UserManagement")" class="btn btn-default alert-success">

                <span class="glyphicon glyphicon glyphicon-plus"></span>
                Add New
            </a>
        </span>
        Manage Users
    </h2>
    
    @if (!ViewData.ModelState.IsValid)
    {
        <div class="bs-callout bs-callout-danger text-danger">
            @Html.ValidationSummary()
        </div>
    }
    
    <table class="table table-striped">
        <thead>
            <tr>
                <th>UserName</th>
                <th>Can Edit</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            @foreach (var user in Model.Users)
            {
                <tr>
                    <td>
                        @user.UserName
                    </td>
                    <td>
                        @if (user.CanEdit)
                        {
                            <span class="glyphicon glyphicon-ok text-success"></span>
                        }
                        else
                        {
                            <span class="glyphicon glyphicon-remove text-danger"></span>
                        }
                    </td>
                    <td class="text-right">
                        
                        @using (Html.BeginForm("Delete", "UserManagement", FormMethod.Post, new { @Class="triggerModal", data_rc_ModalAction ="DeleteGet", data_rc_ModalController="UserManagement"}))
                        {
                            @Html.AntiForgeryToken()
                            <input type="hidden" value="@user.UserName" name="userName" id="userName"/>
                            <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-trash"></span></button>
                        }

                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>

